/*
 * @Author: Your name
 * @Date:   2020-11-30 10:33:31
 * @Last Modified by:   Your name
 * @Last Modified time: 2020-11-30 10:33:31
 */
import Vue from 'vue'
import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import sidebar from './modules/sidebar'
import tagsView from './modules/tagsView'
import getters from './getters'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        msg: true,
        keep: true,
        keepAliveNameList: [],
        routerList: [],
        searchMenuList: []
    },
    mutations: {
        set(state, tab) {
            state.msg = tab
        },
        addKeepAliveName(state, routerName) {
            var index = state.keepAliveNameList.findIndex((item, index) => {
                return item === routerName
            })
            if (index === -1) {
                state.keepAliveNameList.push(routerName)
            }
        },
        removeKeepAliveName(state, routerName) {
            var index = state.keepAliveNameList.findIndex((item, index) => {
                return item === routerName
            })
            if (index > -1) {
                state.keepAliveNameList.splice(index, 1)
            }
        },
    },
    modules: {
        app,
        user,
        sidebar,
        tagsView
    },
    getters
})
